package com.allwees.bs.module.mms.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.allwees.bs.module.mms.entity.SupplierApply;
import com.allwees.core.dao.mybatis.dao.BaseDao;

import java.util.List;

/**
 *
 *
 * @author yangylsky
 * @since 2019-12-03
 *
 */
public interface SupplierApplyDao extends BaseDao<SupplierApply> {

    /**
     * 根据phone、email、username查询
     * @param phone
     * @return
     */
    default List<SupplierApply> selectByCompanyNameAndEmailAndPhone(String companyName, String email, String phone) {
        QueryWrapper<SupplierApply> wrapper = new QueryWrapper<>();
        wrapper.eq("company_name", companyName)
                .or()
                .eq("email", email)
                .or()
                .eq("phone", phone);
        return selectList(wrapper);
    }

    /**
     * 根据手机号查询
     * @param phone
     * @return
     */
    default SupplierApply selectByPhone(String phone) {
        return findOneByField("phone", phone);
    }
}
